<template>
  <div>
     用户 特权
    <div>
      <el-button type="primary" @click="toFormHandler">新增</el-button>
      <el-table :data="rolePrivilege" style="width: 100%">
        <el-table-column prop="id" label="序号" width="180">
        </el-table-column>
        <el-table-column prop="roleId" label="角色序号" width="180">
        </el-table-column>
        <el-table-column prop="privilegeId" label="特权序号" width="180"> </el-table-column>
        <el-table-column width="100" align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="editHandler(scope.row)">修改</el-button>
            <el-button type="text" @click="deleteHandler(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { del,get } from "@/utils/request";
export default {
  data() {
    return {
      rolePrivilege: [],
      visible: false
    };
  },
  methods: {
    loadRolePrivilegen() {
      let url = "http://120.77.41.127:8888/rolePrivilege/query";
      get(url).then(resp => {
        this.rolePrivilege = resp.data;
      });
    },
     toFormHandler() {
      this.$router.push({ path: "/fqh/RolePrivilege_Form" });
    },
    editHandler(row) {
      this.$router.push({
        path: "/fqh/RolePrivilege_form",
        query: row
      });
    },
    deleteHandler(row){
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url = "http://120.77.41.127:8888/rolePrivilege/deleteById"
        del(url,{id:row.id}).then(resp =>{
          // 1. 提示
          this.$message({type:"success",message:resp.message});
          // 2. 刷新
          this.loadRolePrivilegen();
        })
      })
    },
  },
  created() {
    this.loadRolePrivilegen();
  }
    
};
</script>

<style lang="sass" scoped>

</style>
